package database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class AppDatabase extends SQLiteOpenHelper {
	
    private static String DATENBANK_NAME = "app.db";
    private static int DATENBANK_VERSION = 4;
	
	public AppDatabase(Context context) {
		super(context, DATENBANK_NAME, null, DATENBANK_VERSION);
	}	
	
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(INewsTable.CREATE);
		db.execSQL(INotenTable.CREATE);
		db.execSQL(IStundenplanTable.CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL(INewsTable.DELETE);
		db.execSQL(INotenTable.DELETE);
		db.execSQL(IStundenplanTable.DELETE);
		onCreate(db);
	}
	
	public void deleteData(SQLiteDatabase db) {
		db.execSQL("DELETE FROM News");
		db.execSQL("DELETE FROM Noten");
		db.execSQL("DELETE FROM Stundenplan");
	}
}
